package option;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Return implements Ioperate{
    @Override
    public void work(BookList bookList) {
        System.out.println("输入你要归还的图书的名字：");
        Scanner scan = new Scanner(System.in);
        String bookName = scan.nextLine();

        int size = bookList.getCurSize();
        int i = 0;
        while(i<size){
            Book book = bookList.getBooks(i);
            if(book.getName().equals(bookName)){
                if(book.isIs_borrow() == true){
                    book.setIs_borrow(false);
                    System.out.println("成功归还此书......");
                }else {
                    System.out.println("该书已被归还......");
                }
            }
            i++;
        }

        if(i==size){
            System.out.println("找不到该书.....");
        }
    }
}
